<?php
$segmento = new Zend_Session_Namespace('segmento');
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
?>

<div class="barra-pr">
    <div class="st-limite">
        
        <?php if(!Zend_Auth::getInstance()->hasIdentity() && empty(Zend_Auth::getInstance()->getStorage()->read()->USU_LOGIN)) { ?>
        <div class="login" id="hlogin">
            <form id="form_login" method="post">
                <input type="text" id="fl_usuario" name="l_usuario" placeholder="usu&aacute;rio" value=""/>
                <input type="password" id="fl_senha" name="l_senha" placeholder="senha"/>
                <?php /*
                <div class="cnt-btn-login">
                    <a href="javascript:void(0)" onclick="$('#form_login').submit()">login</a>
                     
                    &nbsp; | &nbsp;
                    <a href="<?php echo $this->urlbase;?>/login/cadastro"><i>cadastra-se</i></a>
                    <a href="javascript:void(0)"><i>esqueci a senha</i></a>    
                    
                </div>
                */ ?> 
            </form>
        </div>
        <?php } ?>
        <?php /*
        <div class="ferramentas">
            <a href="#">meus pedidos</a>
            &nbsp; | &nbsp;
            <a href="#" class="carrinho">carrinho</a>
            &nbsp; | &nbsp;
            <a href="#">fechar pedido</a>
            <?php if(Zend_Auth::getInstance()->hasIdentity() && isset(Zend_Auth::getInstance()->getStorage()->read()->USU_LOGIN)) { ?>
            &nbsp; | &nbsp;
            <a href="#" class="conta"></a>
            <?php } ?>
        </div>
        */ ?>
        
        <?php if(Zend_Auth::getInstance()->getStorage()->read()->USU_LOGIN > ''){ ?>
        <div class="ola">
            <?php echo 'Olá '.Zend_Auth::getInstance()->getStorage()->read()->USU_NOME.'.'; ?>
            &nbsp;
            <a href="<?php echo $this->urlbase;?>/login/logout">Sair.</a>
        </div>
        <?php } ?>
        
        <div class="pesquisa">
            <form action="<?php echo $this->urlbase.'/index/';?>" method="get">
                <input type="text" name="pesquisar" placeholder="pesquisar" />
                <input type="submit" class="submit" value=""/> 
            </form>
        </div>
    </div>
</div>
<div class="barra-sg">
    <div class="st-limite">
        <h1 class="logo<?php echo $segmento->CTS_ID;?>"><a href="<?php echo $this->urlbase;?>/" title="D&CloseCurlyQuote;Marco Uniformes"></a></h1>
        <nav>
            <ul class="menu-principal">
                <li><a href="<?php echo $this->urlbase;?>/quemsomos">quem somos</a></li>
                <li><a href="<?php echo $this->urlbase;?>/cases">cases</a></li>
                <li><a href="<?php echo $this->urlbase;?>/dicas">dicas</a></li>
                <li><a href="<?php echo $this->urlbase;?>/contato">contatos</a></li>
            </ul>
        </nav>
    </div>
</div>

<?php
if($this->controller == 'index' || $this->controller == '') { ?>
<?php /* 
<div class="cnt-slider hom">
    <?php
    $obj = new Sistema_Model_DbTable_Fullbanner();
    $banner = $obj->fetchAll($obj->select()->where('BAN_STA = 1 and CTS_ID = '.$segmento->CTS_ID)->order('BAN_ORD ASC'));

    foreach($banner as $ban) {
        $img = 'public/upload/fullbanner/'.$ban->BAN_ID.'.*';
        foreach (glob($img) as $src) {
          $img = $src;
        } 
    ?>
    <a href="<?php echo $ban->BAN_LNK;?>">
        <img src="<?php echo $this->urlbase.'/'.$img;?>" height="400px" width="100%"/>
    </a>
    <?php  }  ?>
</div>

<div class="nav-slider">
    <a href="#" id="prev"></a>
    <a href="#" id="next"></a>
</div>
*/ ?>
<div class="cnt-slider hom">
    <?php
    $posicao= 50;
    $query = 'SELECT SQL_CACHE * FROM FULLBANNER WHERE BAN_STA = 1 and CTS_ID = '.$segmento->CTS_ID.' ORDER BY BAN_ORD ASC';
    $banner = $db->fetchAll($query);
    
    foreach($banner as $key => $ban) {
        $img = 'public/upload/fullbanner/'.$ban['BAN_ID'].'.*';
        foreach (glob($img) as $src) {
          $img = $src;
        }
        
        $style = '';
        $class = '';
        
        if($key > 0) $style = 'display: none;';
        if($key == 0) $class = 'class="action"';
        
        $alink .= '<a '.$class.' id="lnkb'.$key.'" itemref="bimg'.$key.'" itemid="'.$key.'" href="javascript:void(0)"></a>';
        $imgs .= '<img id="bimg'.$key.'" src="'.$this->urlbase.'/'.str_replace('.','_sld.',$img).'" style="margin-left: '.$posicao.'px" >';
        
        $posicao += 34; 
        
    ?>
    <a href="<?php echo $ban['BAN_LNK'];?>">
        <div id="banner<?php echo $key; ?>" class="banner" style="background-image: url('<?php echo $this->urlbase.'/'.$img; ?>');<?php echo $style; ?>"></div>    
    </a>
    <?php  }  ?>
    
    <div class="lnkitg">
        <div class="imgs"><?php echo $imgs; ?></div>
        <?php echo $alink; ?>
    </div>
    
</div>



<div class="st-limite">
    
    <div class="prod-destaque">
        <div class="imagem">
            <img src="<?php echo $this->urlbase;?>/public/media/images/icone_produtosdestaque.png" />
        </div>
        <div class="slider-prod">
            <?php

            $dir_pro = 'public/upload/produto/';

            $prods = $db->fetchAll('SELECT SQL_CACHE PRO_ID,PRO_NOM FROM PRODUTO WHERE PRO_STAPRO = 1 and PRO_STA = 1 and CTS_ID = '.$segmento->CTS_ID.' ORDER BY PRO_QTDACE DESC, PRO_NOM ASC');
            ?>
            <ul>
                <?php foreach($prods as $key => $pro) { 
                    $img = glob($dir_pro.$pro['PRO_ID'].'_*_hcp.*');
                ?>
                <li id="<?php echo $key; ?>">
                    <a href="<?php echo $this->url(array('controller' => 'produto', 'action' => 'detalhe', 'id' => $pro['PRO_ID'])); ?>">
                        <img src="<?php echo $this->urlbase.'/'.$img[0];?>"  />
                    </a>
                    <div class="des-prod">
                        <div class="content-info">
                            <i style="margin-top: 2px;"><?php echo $this->segmento->CTS_NOM; ?></i><br>
                            <strong><?php echo $pro['PRO_NOM']; ?></strong> 
                            <a href="<?php echo $this->url(array('controller' => 'produto', 'action' => 'detalhe', 'id' => $pro['PRO_ID'])); ?>" class="comprar a<?php echo $segmento->CTS_ID ?>"><span>solicite orçamento</span></a><?php // adicionar ao carrinho ?>
                        </div>
                    </div>
                </li>
                <?php } ?>
            </ul>
        </div>
    </div>
    <a href="" id="st-lk-tp"></a>
    <?php /* 
    <script src="<?php echo $this->urlbase;?>/public/media/js/jquery.cycle.all.min.js" type="text/javascript"></script>
    */ ?>
    <script src="<?php echo $this->urlbase;?>/public/media/js/jquery.jcarousel.min.js" type="text/javascript"></script>
    <script>
    $(document).ready(function() {  
        <?php /*  $('.cnt-slider').cycle({ fx: 'scrollHorz', timeout: 8000, prev: '#prev', next: '#next' });  */ ?> 
        $('.slider-prod').jcarousel({ auto: 5, scroll: 1, wrap: 'circular'  }); // , 
    });
    </script>
    <?php   } else { ?>
        <div class="cnt-slider int">
    <?php 
           $query = 'SELECT SQL_CACHE PAG_ID FROM PAGINASSITE WHERE PAG_MODULO like "'.$this->controller.'" and CTS_ID = '.$segmento->CTS_ID;
           $row = $db->fetchRow($query);
           if(isset($row['PAG_ID'])) {
               $img = 'public/upload/paginassite/'.$row['PAG_ID'].'.*';
               foreach (glob($img) as $src) {
                   $img = $src;
               }
               /* <img src="<?php echo $this->urlbase.'/'.$img;?>"  height=200px"  width="100%" /> */
               ?> 
                <div  class="b_pagina" style="background-image: url('<?php echo $this->urlbase.'/'.$img; ?>');<?php echo $style; ?>"></div>
               
           <?php  } ?>
        </div>
    <?php   } ?>

</div>
